<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Tests for sdOpenapi.js</title>
    <link rel="stylesheet" type="text/css" href="css/jsUnitStyle.css">
    <script type="text/javascript" src="app/jsUnitCore.js"></script>
		<script type="text/javascript" src="../lib/mootools-1.2-core-NoReq.js"></script>
    <script type="text/javascript" src="jsUnitAjax.js"></script>
    <script type="text/javascript" src="../lib/request.js"></script>
    <script type="text/javascript" src="../lib/sdOpenapi.js"></script>
    <script type="text/javascript">

        function setUp() {
        }

        function checkDate(aTitle, aDate, aUTCFullYear, aUTCMonth, aUTCDate, aUTCHours, aUTCMinutes, aUTCSeconds, aUTCMilliseconds){
            assertEquals(aTitle+ " date type error:", "date", $type(aDate));
            assertEquals(aTitle+ " FullYear Error:", aUTCFullYear, aDate.getUTCFullYear());
            assertEquals(aTitle+ " Month Error:", aUTCMonth-1, aDate.getUTCMonth());
            assertEquals(aTitle+ " Date Error:", aUTCDate, aDate.getUTCDate());
            assertEquals(aTitle+ " Hours Error:", aUTCHours, aDate.getUTCHours());
            assertEquals(aTitle+ " Minutes Error:", aUTCMinutes, aDate.getUTCMinutes());
            assertEquals(aTitle+ " Seconds Error:", aUTCSeconds, aDate.getUTCSeconds());
            assertEquals(aTitle+ " Milliseconds Error:", aUTCMilliseconds, aDate.getUTCMilliseconds());
        }

        function testIso8601StrToDate() {
            var aDate = SNDA.strToDate("Hello world ABC");
            assertEquals("string", $type(aDate));
            assertEquals("Hello world ABC", aDate);

            var aDate = SNDA.strToDate("2007-01-01T13:55:32.3334+08:00");
            checkDate("1", aDate, 2007, 1, 1, 13-8, 55, 32, 333);

            var aDate = SNDA.strToDate("2008-01-18T13:55:32.3334Z");
            checkDate("2", aDate, 2008, 1, 18, 13, 55, 32, 333);
            //alert(SNDA.dateToStr(aDate));
            var aDate = SNDA.strToDate("20180228T165012.133Z");
            checkDate("3", aDate, 2018, 2, 28, 16, 50, 12, 133);

            var aDate = SNDA.strToDate("20090301Z");
            checkDate("4", aDate, 2009, 3, 1, 0, 0, 0, 0);

            var aDate = SNDA.strToDate("20090301");
            checkDate("5", aDate, 2009, 3, 1, 0, 0, 0, 0);

            //assertObjectEquals('header error:', headers, aReq.options.headers);
            //assertTrue(aReq.options.async);
            //assertEquals(true, aReq.options.async);
        }
        
        function testDateToIso8601Str() {
            var aDate = SNDA.strToDate("2008-01-18T13:55:32.3334Z");
            checkDate(aDate, aDate, 2008, 1, 18, 13, 55, 32, 333);
            assertEquals('dateToStr Error:', "2008-01-18T13:55:32.333Z", SNDA.dateToStr(aDate));
        }


    </script>

</head>

<body>
<h1>JsSNDA SNDA Tests</h1>
<div align="right">Architect: Riceball LEE(riceballl@hotmail.com)</div>

<p>This page contains tests for the JsSNDA sdOpenapi library. To see them, take a look at the source.</p>
</body>
</html>